/* Creacio de un .ics*/
function creaCSVCalendar(mail){

    var peticion_http = null;
   
    if(window.XMLHttpRequest) peticion_http = new XMLHttpRequest();
    else if(window.ActiveXObject) peticion_http = new ActiveXObject("Microsoft.XMLHTTP");
    peticion_http.onreadystatechange = divCreacioEvent;
    peticion_http.open("POST", "../../projecte-sintesi-dani-victor/site_media/php/descargarCVS.php", false);
    peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");   
    peticion_http.send("mail="+mail);
    

    function divCreacioEvent() { 
        if(peticion_http.readyState == 4 && peticion_http.status == 200 ) {
            ruta = peticion_http.responseText;
            startDownload(ruta);
        }
    }
   
   function startDownload(ruta){
       
        var url= "../../projecte-sintesi-dani-victor/site_media/php/extras/export/" + ruta;    
        window.open(url,'Download');  
    }    
    
}
/*FI creacio de un .ics*/

/*Importació d'un calendari*/
function importaCSVCalendar(mail){
   // alert(mail);
   var peticion_http = null;
   
    if(window.XMLHttpRequest) peticion_http = new XMLHttpRequest();
    else if(window.ActiveXObject) peticion_http = new ActiveXObject("Microsoft.XMLHTTP");
    peticion_http.onreadystatechange = divCreacioEvent;
    peticion_http.open("POST", "../../projecte-sintesi-dani-victor/site_media/php/crear_button_file.php", true);
    peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");   
    peticion_http.send("mail="+mail);
    

    function divCreacioEvent() { 
        if(peticion_http.readyState == 4 && peticion_http.status == 200 ) {
           // alert(peticion_http.responseText);
            var miDiv = document.createElement("div");         
            miDiv.setAttribute("id", "Cranc");
            miDiv.setAttribute("style", "position: absolute; top:10%;left:13%; background-color: Gray;height:450 ;min-height:450;width:75%;z-index:9;padding:2em;");
            miDiv.innerHTML = peticion_http.responseText;
            document.getElementById('eventos').appendChild(miDiv);          
        }
    }
}
 




